import Vue from "vue";
import App from "./App.vue";
// 路由引入
import router from "./router";
// vuex引入
import store from "./store";
// 移动端适配
import "lib-flexible/flexible"
import './assets/style/common.css'
// 样式重置  解决移动端1px边框问题
import './assets/style/border.css';
Vue.config.productionTip = false;
// import {Toast} from 'vant'
// vant-ui 按需引入
import {SubmitBar,NavBar,Card,Checkbox,CheckboxGroup,Toast,Tab, Tabs, GoodsAction, GoodsActionIcon, GoodsActionButton,Sidebar, SidebarItem,Tabbar,List ,TabbarItem,Search,Icon,Swipe,SwipeItem,PullRefresh,Cell, CellGroup,Form,Field,Button,Image } from 'vant'
Vue.use(SubmitBar);
Vue.use(NavBar);
Vue.use(Card);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Toast)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(GoodsAction)
Vue.use(GoodsActionIcon)
Vue.use(GoodsActionButton)
Vue.use(Tabbar)
Vue.use(Sidebar)
Vue.use(SidebarItem)
Vue.use(List)
Vue.use(TabbarItem)
Vue.use(Search)
Vue.use(Icon)
Vue.use(Swipe)
Vue.use(SwipeItem)
Vue.use(PullRefresh)
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(Form);
Vue.use(Field);
Vue.use(Button);
Vue.use(Image);
// 路由拦截
router.beforeEach((to, from, next) => {
  console.log(from);
  if (to.name == "login") {
    store.dispatch("changeNavFlag", 'aaa'); //隐藏导航栏
  }else if(to.name == "cart"){
    store.dispatch("changeNavFlag", 'aaa'); //隐藏导航栏
  } else if(to.name == "info"){
    store.dispatch("changeNavFlag", 'ccc'); //显示添加购物车
  }else{
    store.dispatch("changeNavFlag", 'bbb'); //显示导航栏
  }
  next();
});
// router.beforeEach((to,from,next)=>{
//   // console.log(1,to)
//   // console.log(2,from)
//   if(to.name == from.name){
//     Toast.fail("玛了巴子")
//   }else{
//     next()
//   }
// })
// 将路由 和 vuex的store库 挂载
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
